import { action, observable } from 'mobx';
import { listRole } from '../../role/service';

class RoleStore {


  // 角色弹出框需要用到的参数
  @observable roleDialogData = {
    visible: false,
    allRoles: [],
    roles: [],
  };


  @action
  async orgOnload(option) {
    this.roleDialogData = { ...this.roleDialogData, allRoles: await listRole(option.row.id) };
  }

  @action
  async orgSelect(key) {
    this.roleDialogData = { ...this.roleDialogData, allRoles: await listRole(key) };
  }

  /**
   * 打开用户编辑窗口
   * @param
   */
  async showRoleDialog(data) {
    this.roleDialogData = { ...this.roleDialogData, visible: true, ...data };
  }

  /**
   * 关闭可选角色对话框
   */
  @action
  closeRoleDialog() {
    this.roleDialogData.visible = false;
  }
}

export default RoleStore;
